const Sequelize = require("sequelize");
const {List} = require("../models/list");

const Op = Sequelize.Op;

const listService = {
    // 获取普通列表
    async getBasicTable(page, pageSize) {
        const currentPage =  parseInt(page);
        const size = parseInt(pageSize);
        return List.findAll({
            attributes: ["id", "time", "name", "address"],
            offset: size * (currentPage - 1),
            limit: size,
        })
    },

    // 获取分页列表
    async getPageTable(page, pageSize) {

        const currentPage =  parseInt(page);
        const size = parseInt(pageSize);
        return List.findAll({
            attributes: ["id", "time", "name", "address", "status"],
            offset: size * (currentPage - 1),
            limit: size,
        })
    },

    // 获取复杂表格
    async getComplexTable(page, pageSize) {

        const currentPage =  parseInt(page);
        const size = parseInt(pageSize);
        return List.findAll({
            offset: size * (currentPage - 1),
            limit: size,
        })
    }
};

module.exports = listService;
